package org.lld.im.service.group.controller;

import org.lld.im.common.ResponseVO;
import org.lld.im.service.group.model.req.*;
import org.lld.im.service.group.service.ImGroupMemberService;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

/**
 * @author: LunBoWang
 * @description: 群组成员控制类
 * @date: 2025/3/17 下午8:21
 * @version: 1.0
 */
@RestController
@RequestMapping("v1/group/member")
public class ImGroupMemberController {

    @Resource
    ImGroupMemberService imGroupMemberService;

    // 导入群成员
    @PostMapping("/importGroupMember")
    public ResponseVO importGroupMember(@RequestBody @Validated ImportGroupMemberReq req, Integer appId, String identifier) {
        req.setAppId(appId);
        req.setOperator(identifier);
        return imGroupMemberService.importGroupMember(req);
    }

    //添加群成员
    @PostMapping("/addMember")
    public ResponseVO addMember(@RequestBody @Validated AddGroupMemberReq req, Integer appId, String identifier) {
        req.setAppId(appId);
        req.setOperator(identifier);
        return imGroupMemberService.addMember(req);
    }

    //删除群成员
    @DeleteMapping("/remove")
    public ResponseVO removeMember(@RequestBody @Validated RemoveGroupMemberReq req, Integer appId, String identifier) {
        req.setAppId(appId);
        req.setOperator(identifier);
        return imGroupMemberService.removeMember(req);
    }

    //更新群成员信息
    @PutMapping("/update")
    public ResponseVO updateGroupMember(@RequestBody @Validated UpdateGroupMemberReq req, Integer appId, String identifier) {
        req.setAppId(appId);
        req.setOperator(identifier);
        return imGroupMemberService.updateGroupMember(req);
    }

    //禁言群成员
    @PutMapping("/speak")
    public ResponseVO speak(@RequestBody @Validated SpeaMemberReq req, Integer appId, String identifier) {
        req.setAppId(appId);
        req.setOperator(identifier);
        return imGroupMemberService.speak(req);
    }
}
